#!/usr/bin/env bash
set -e
set -u
set -o pipefail


source "${BASH_SOURCE%/*}/assertions.sh"


test_get_directory_depth_offset() {
    local path=${1:?}
    source "${BASH_SOURCE%/*}/../src/utils/functions.sh"
    get_directory_depth_offset "$path"
}


test_get_directory_depth_offset_main() {
    assert_equal \
        "test_get_directory_depth_offset" \
        "./" \
        "$(test_get_directory_depth_offset "foo.html")"
    assert_equal \
        "test_get_directory_depth_offset" \
        "./" \
        "$(test_get_directory_depth_offset "./foo.html")"
    assert_equal \
        "test_get_directory_depth_offset" \
        "./../" \
        "$(test_get_directory_depth_offset "./bar/foo.html")"
    assert_equal \
        "test_get_directory_depth_offset" \
        "./../../" \
        "$(test_get_directory_depth_offset "./baz/bar/foo.html")"
    assert_equal \
        "test_get_directory_depth_offset" \
        "./../../../" \
        "$(test_get_directory_depth_offset "./fip/baz/bar/foo.html")"
}


test_get_directory_depth_offset_main
